const wssrouter = require('koa-router')()

var mode = 1 //0预览 1开始
var level = 1  //1限制 2预览 3 3等 4 2等 5 1等 6 特等
wssrouter.get('/scj', async (ctx, next) => {
    if (!ctx.request.query.level) {
        level = 1
    }
    level = ctx.request.query.level
    ctx.body = {
        level: level
    }
})
wssrouter.get('/scjm', async (ctx, next) => {
    if (!ctx.request.query.mode) {
        mode = 1
    }
    mode = ctx.request.query.mode
    ctx.body = {
        mode: mode
    }
})

wssrouter.get('/cjm', async (ctx, next) => {
    ctx.body = {
        mode: mode
    }
})
wssrouter.get('/ocj', async (ctx, next) => {
    ctx.body = {
        level: level
    }
})
wssrouter.get('/cj', async (ctx, next) => {
    ctx.body = {
        level: level
    }
    if (mode == 1) {
        level = 1
    }
})






module.exports = {
    WebSocketApi: (wss) => {
        // 当有客户端连接时
        wss.on('connection', function connection(ws) {
            // 当收到消息时
            ws.on('message', async function incoming(message) {
       
            });

            // 当连接关闭时
            ws.on('close', function () {

            });
        });
    },
    wssrouter: wssrouter
}

